package com.sdr.sluicemapplugin.adapter;

import android.app.Activity;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.sdr.xitang.R;
import com.sdr.sluicemapplugin.bean.WaterGateBean;

import java.util.List;

/**
 * Created by HeYongFeng on 2016/10/28.
 */
public class RightListViewAdapter extends BaseAdapter{
    private String userId ;
    private List<WaterGateBean> datas;
    private Activity mActivity ;

    public RightListViewAdapter(String userId,List<WaterGateBean> datas, Activity activity) {
        this.datas = datas;
        mActivity = activity;
        this.userId = userId;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = View.inflate(mActivity, R.layout.simple_list_item,null);
        TextView textView = (TextView) view.findViewById(R.id.tv_rightmenu_title);
        ImageView iv_task = (ImageView) view.findViewById(R.id.iv_rightmenu_task);
        textView.setText(datas.get(position).getName());
        if (userId.equals(datas.get(position).getPatrolUserID()+"")){
//            textView.setTextColor(Color.parseColor("#72D3E4"));
            iv_task.setVisibility(View.VISIBLE);
        }else {
//            textView.setTextColor(Color.parseColor("#737373"));
            iv_task.setVisibility(View.INVISIBLE);
        }
        return view;
    }
}
